Skip to content

Backport(v1.19) output: enforce strict path boundary validation for tag#5391

Merged
kenhys merged 1 commit into
v1.19from
backport/output
Jun 25, 2026
Merged

Backport(v1.19) output: enforce strict path boundary validation for tag#5391
kenhys merged 1 commit into
v1.19from
backport/output

Conversation

@Watson1978

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:
Fixes #

What this PR does / why we need it:
This PR enhances the robustness of the ${tag} placeholder expansion by preventing unintended path boundaries from being crossed.

Previously, tags containing relative parent directory patterns (../) or absolute paths (e.g., /etc/passwd, \Windows) were expanded without validation in extract_placeholders. This could lead to unexpected file creation or access outside of the intended base directories, especially when using plugins like out_file.

To address this, we introduced a strict, highly optimized path boundary validation inside extract_placeholders specifically for the ${tag} variable.

  • By validating the variable before substitution, all core and third-party plugins using extract_placeholders automatically benefit from this boundary check.
  • Backward Compatibility
    • Tags containing safe slashes (e.g., app/web) are still permitted, ensuring URL expansions (e.g., in out_http) or safe nested directories remain fully functional.

Docs Changes:

Release Note:

**Which issue(s) this PR fixes**:
Fixes #

**What this PR does / why we need it**:
This PR enhances the robustness of the `${tag}` placeholder expansion by preventing unintended path boundaries from being crossed.

Previously, tags containing relative parent directory patterns (`../`) or absolute paths (e.g., `/etc/passwd`, `\Windows`) were expanded without validation in `extract_placeholders`. This could lead to unexpected file creation or access outside of the intended base directories, especially when using plugins like `out_file`.

To address this, we introduced a strict, highly optimized path boundary validation inside `extract_placeholders` specifically for the `${tag}` variable.

* By validating the variable before substitution, all core and third-party plugins using `extract_placeholders` automatically benefit from this boundary check.
* Backward Compatibility
  * Tags containing safe slashes (e.g., `app/web`) are still permitted, ensuring URL expansions (e.g., in `out_http`) or safe nested directories remain fully functional.

**Docs Changes**:

**Release Note**:

Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
@Watson1978 Watson1978 requested a review from kenhys June 25, 2026 06:53
@kenhys kenhys changed the title output: enforce strict path boundary validation for tag Backport(v1.19) output: enforce strict path boundary validation for tag Jun 25, 2026
@kenhys kenhys merged commit 45c87a8 into v1.19 Jun 25, 2026
17 of 19 checks passed
@kenhys kenhys deleted the backport/output branch June 25, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants